/*
 * @lc app=leetcode.cn id=1614 lang=javascript
 *
 * [1614] 括号的最大嵌套深度
 */

// @lc code=start
/**
 * @param {string} s
 * @return {number}
 */
var maxDepth = function (s) {
  if (s.length <= 1) {
    return 0;
  }

  let max = 0;
  let stack = [];
  for (const ch of s) {
    switch (ch) {
      case "(":
        stack.push(1);
        max = Math.max(max, stack.length);
        break;
      case ")":
        stack.pop();
        break;
    }
  }

  return max;
};
// @lc code=end
